use std::cell::RefCell;
use std::rc::Rc;
use crate::instruction::instruction::Instruction;
use crate::vm_thread::{VMFrame, VMThread};
use crate::vm_val::{VMValDouble, VMValEnum};

pub struct dconst_0 {}

impl Instruction for dconst_0 {
    fn exec(&mut self, frame: Rc<RefCell<VMFrame>>, thread: &VMThread) {
        frame.borrow().operand_stack.borrow_mut().push(VMValEnum::VMValDouble {
            val: VMValDouble {
                num: 0.0
            }
        });
    }

    fn to_string(&self) -> String {
        String::from("dconst_0")
    }
}


pub struct dconst_1 {}

impl Instruction for dconst_1 {
    fn exec(&mut self, frame: Rc<RefCell<VMFrame>>, thread: &VMThread) {
        frame.borrow().operand_stack.borrow_mut().push(VMValEnum::VMValDouble {
            val: VMValDouble {
                num: 1.0
            }
        });
    }

    fn to_string(&self) -> String {
        String::from("dconst_1")
    }
}